if( SERVER ) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight	= 50
	SWEP.AutoSwitchTo = false
	SWEP.AutoSwitchFrom = false
end

if( CLIENT ) then
	SWEP.PrintName	= "Seringue de Drogue"
	SWEP.Slot	= 4
	SWEP.SlotPos	= 1
	SWEP.DrawAmmo	= false
	SWEP.DrawCrosshair = false
end

SWEP.Base		= "weapon_base"

SWEP.Author		= "Enrico"
SWEP.Instructions	= "Primary: drogue quelqun - Secondary: auto drogue "
SWEP.Contact		= ""
SWEP.Purpose		= ""

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none" 
  
SWEP.ViewModel      = ""
SWEP.WorldModel   = ""

util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.wav")
util.PrecacheSound("ambient/machines/slicer3.wav")

function SWEP:Initialize()
	if( SERVER ) then
		self:SetWeaponHoldType( "normal" )
	end
end

function SWEP:PrimaryAttack()
	self.Weapon:SetNextPrimaryFire(CurTime()+5)
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
 	local trace = self.Owner:GetEyeTrace()
	if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
		if trace.Entity:IsValid() and trace.Entity:IsPlayer() then
			self.Weapon:EmitSound("ambient/machines/slicer3.wav", 100)
			if CLIENT then return end
			local rp = RecipientFilter()
			rp:AddPlayer(trace.Entity)
			umsg.Start("Tranq", rp)
			umsg.End()
			umsg.Start("Tranq", rp)
			umsg.End()
			self.Owner:StripWeapon("weapon_seringue_de_drogue")
		else
			self.Weapon:EmitSound("weapons/iceaxe/iceaxe_swing1.wav", 50)
		end
	else
		self.Weapon:EmitSound("weapons/iceaxe/iceaxe_swing1.wav", 50)
	end
end

function SWEP:SecondaryAttack()
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
	self.Weapon:EmitSound("ambient/machines/slicer3.wav", 100)
	if CLIENT then return end
	local rp = RecipientFilter()
	rp:AddPlayer(self.Owner)
	umsg.Start("Tranq", rp)
	umsg.End()
	umsg.Start("Tranq", rp)
	umsg.End()
	self.Owner:StripWeapon("weapon_seringue_de_drogue")
end

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )  
	draw.SimpleText( "C", "CSSelectIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end